<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <input type="text" id="elInput" username="jack" max-time="30" />
    <script>
      const elInput = document.getElementById("elInput");
      const attr = {
        0: {
          name: "type",
          nodeValue: "text",
        },
        1: {
          name: "age",
          nodeValue: "20",
        },
        type: {
          name: "type",
          nodeValue: "text",
        },
        age: {
          name: "age",
          nodeValue: "20",
        },
      };
      // 获取所有特性
      console.log(elInput.attributes);

      console.log(elInput.attributes[0].name);
      console.log(elInput.attributes.type.name);
      console.log(elInput.attributes[0].nodeValue);
      console.log(elInput.attributes.type.nodeValue);

      for (let attr of elInput.attributes) {
        console.log(attr.name);
        console.log(attr.nodeValue);
      }
    </script>
  </body>
</html>
